﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Chemical
{
    public partial class MainWindow : Form
    {
        #region fields

        private Timer m_timer;

        private MathTools.NewtonMethod m_method;

        private MathTools.Tasks.FirstTask m_firstTask;

        #endregion

        public MainWindow()
        {
            InitializeComponent();

            m_firstTask = new MathTools.Tasks.FirstTask();

            m_method = new MathTools.NewtonMethod( m_firstTask );

            m_timer = new Timer();

            m_timer.Interval = 100;

            m_timer.Tick += new EventHandler( m_timer_Tick );
        }

        void m_timer_Tick( object sender, EventArgs e )
        {
            int value = m_method.Progress / 10;

            if( value < 0 || value > 100 )
                value = 100;

            bottomProgressBar.ProgressBar.Value = value;

            if( m_method.Answer == null )
                return;

            m_timer.Stop();

            bottomProgressBar.Visible = false;
        }

        private void inputDataButton_Click( object sender, EventArgs e )
        {
            if( mainTabs.SelectedTab == firstTaskTab )
            {
                return;
            }
        }

        private void startStripButton_Click( object sender, EventArgs e )
        {
            m_timer.Start();

            bottomProgressBar.Visible = true;

            m_firstTask.setKoefs( 1, 1, 1 );

            m_method.runAsynchronly();
        }

    }
}
